home *** CD-ROM | disk | FTP | other *** search
- #include "toolwin.h"
- #include "gadgets.h"
- #include "menu.h"
- #include "screen.h"
-
- #include<intuition/screens.h>
-
- #include<stdio.h>
-
- #include<clib/gadtools_protos.h>
- #include<clib/intuition_protos.h>
-
- /* Global record of our tool window */
- struct Window* toolwin = NULL;
-
- int openToolWin()
- {
- /* Extra protection -- only open if not already open */
- if(toolwin == NULL)
- {
- struct Screen* scr = getScreen();
- struct Menu* menu = getMenuStrip();
- /* The minimal height of our tool window */
- int h = gadgetHeight() + scr->WBorTop + (scr->Font->ta_YSize + 1) + scr->WBorBottom;
- /* Open our tool window */
- if(toolwin = OpenWindowTags(NULL,
- WA_Left, 0,
- WA_Top, scr->Height - h,
- /* Make the window sit in the bottom of the screen */
- WA_Width, scr->Width,
- WA_Height, h,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR,
- WA_IDCMP, IDCMP_CLOSEWINDOW | BUTTONIDCMP | IDCMP_REFRESHWINDOW | IDCMP_MENUPICK,
- WA_Gadgets, getGadgets(),
- WA_CustomScreen, scr,
- WA_Title, "Tools",
- TAG_DONE, 0))
- {
- /* Attach menu strip to tool window, as well */
- if(SetMenuStrip(toolwin, menu))
- {
- /* Let GadTools refresh its bits of the tool window */
- GT_RefreshWindow(toolwin, NULL);
- return TRUE;
- }
- else
- printf("Error: could not attach menus to tool window\n");
- }
- else
- printf("Error: could not open tool window\n");
- }
- else
- {
- printf("Warning: tool window already open\n");
- /* Only a warning, so don't return NULL */
- return TRUE;
- }
- return FALSE;
- }
-
- void closeToolWin()
- {
- if(toolwin)
- {
- ClearMenuStrip(toolwin);
- CloseWindow(toolwin);
- toolwin = NULL;
- }
- }
-
- struct Window* getToolWin()
- {
- return toolwin;
- }
-
- ULONG getToolSig()
- {
- return toolwin ? 1L << toolwin->UserPort->mp_SigBit : 0L;
- }
-